package com.cn.contorller;

import com.cn.vo.PostUserEntityReqVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: springcloud-example
 * @description:
 * @author:
 * @create: 2018-06-15 16:12
 **/
@Controller
public class ClientController {

    @GetMapping("/getNullUser")
    @ResponseBody
    public String getNullUser() {
        System.out.println("getUser获取用户成功");
        return "\"getUser\" : {\"username\":\"Tom\",\"age\":\"10\"}";
    }

    @GetMapping("/getUser")
    @ResponseBody
    public String getUser(@RequestParam String name) {
        System.out.println("getUser获取用户成功");
        return "\"getUser\" : {\"username\":\"" + name + "\",\"age\":\"10\"}";
    }

    @PostMapping("/postNullUser")
    @ResponseBody
    public String postNullUser() {
        System.out.println("postUser获取用户成功");
        return "\"postUser\" : {\"username\":\"Tom\",\"age\":\"10\"}";
    }

    @PostMapping("/postUser")
    @ResponseBody
    public String postUser(@RequestBody String name) {
        System.out.println("postUser获取用户成功");
        return "\"postUser\" : {\"username\":\"" + name + "\",\"age\":\"10\"}";
    }

    @PostMapping("/postUserEntity")
    @ResponseBody
    public String postUserEntity(@RequestBody PostUserEntityReqVO reqVO) {
        System.out.println("postUserEntity获取用户成功");
        return "\"postUserEntity\" : {\"username\":\"" + reqVO.getName() + "\",\"age\":\"10\"}";
    }
}
